import java.util.*;
import java.io.*;

public class WAndRFile {
    String ua=new String();//用户答案
    public void writeToFile(String str){
        File fw=new File("practice.txt");//写入的文件
        try{
            Writer out=new FileWriter(fw);//指向目的地输出流
            BufferedWriter bw=new BufferedWriter(out);
            bw.write(str);//写入字符串str
            bw.newLine();//换行
            bw.close();//高级流关闭
            out.close();//关闭底层流
        }
        catch (IOException e){
            e.printStackTrace();
        }
    }
    public String readFromFile(){
        File fr=new File("practice.txt");//读取的文件
        try{
            Reader in=new FileReader(fr);//指向源的输入流
            BufferedReader br=new BufferedReader(in);
            while (br.readLine()!=null)
                ua=br.readLine();
            br.close();
            in.close();;
        }
        catch (IOException e){
            e.printStackTrace();
        }
        return ua;
    }
}
